home *** CD-ROM | disk | FTP | other *** search
/ EuroCD 3 / EuroCD 3.iso / Programming / vbcc / machines / amigappc / libsrc / time / time.c < prev   
Encoding:
C/C++ Source or Header  |  1998-06-24  |  881 b   |  42 lines

  1. /*
  2. ** vbcc-Amiga-PowerPC version of time.c
  3. **
  4. ** v0.2 14.12.97 phx
  5. **      PPCCallOS for DateStamp() included.
  6. ** v0.1 04.10.97 phx
  7. */
  8.  
  9. #include <time.h>
  10. #include <dos/dos.h>
  11. #include <powerup/gcclib/powerup_protos.h>
  12.  
  13. extern long __gmtoffset;
  14. extern ULONG DOSBase;
  15.  
  16.  
  17. time_t time(time_t *tloc)
  18. {
  19.   struct DateStamp t;
  20.   time_t ti;
  21.   struct Caos MyCaos;
  22.  
  23.   MyCaos.d1 = (ULONG)&t;
  24.   MyCaos.M68kCacheMode = IF_CACHEFLUSHALL;
  25.   MyCaos.PPCCacheMode = IF_CACHEFLUSHALL;
  26.   MyCaos.caos_Un.Offset = -192;
  27.   MyCaos.a6 = DOSBase;
  28.   PPCCallOS(&MyCaos);  /* Get timestamp */
  29.   ti=((t.ds_Days+2922)*1440+t.ds_Minute+__gmtoffset)*60+
  30.       t.ds_Tick/TICKS_PER_SECOND;
  31.   if(tloc!=NULL)
  32.     *tloc=ti;
  33.   return ti;
  34. }
  35.  
  36. /*
  37.  * 2922 is the number of days between 1.1.1970 and 1.1.1978 (2 leap years and 6
  38. normal)
  39.  * 1440 is the number of minutes per day
  40.  *   60 is the number of seconds per minute
  41.  */ 
  42.